package com.example.practice.controller;

import com.example.practice.entity.*;
import com.example.practice.service.CheckService;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Check)表控制层
 *
 * @author makejava
 * @since 2023-12-21 11:38:40
 */
@RestController
@RequestMapping("/api/check")
public class CheckController {
    /**
     * 服务对象
     */
    @Resource
    private CheckService checkService;

    @GetMapping("queryCheckStatus")
    public Check queryCheckStatus(Integer uid,Integer aid){
        return this.checkService.queryCheckStatus(uid,aid);
    }

    //学校
    @ApiOperation("获取要审核的活动")
    @GetMapping("getCheckActivity")
    public List<Activity> getCheckActivity(Integer uid){
        return this.checkService.getCheckActivity(uid);
    }

    @ApiOperation("审核通过")
    @GetMapping("checkPass")
    public String checkPass(Integer aid){
        this.checkService.checkPass(aid);
        return "审核通过";
    }
    @ApiOperation("审核不通过")
    @GetMapping("checkNotPass")
    public String checkNotPass(Integer aid){
        this.checkService.checkNotPass(aid);
        return "审核不通过";
    }
    //    学院
    @ApiOperation("获取要审核的活动")
    @GetMapping("getCheckByCollege")
    public List<Check> getCheckByCollege(Integer uid){
        return this.checkService.getCheckByCollege(uid);
    }

    @ApiOperation("审核通过")
    @GetMapping("checkPassByCollege")
    public Integer checkPassByCollege(Integer uid,Integer aid){
    return this.checkService.checkPassByCollege(uid,aid);
    }
    @ApiOperation("审核不通过")
    @GetMapping("checkNotPassByCollege")
    public Integer checkNotPassByCollege(Integer uid,Integer aid){
        return this.checkService.checkNotPassByCollege(uid,aid);
    }
    @GetMapping("insertCheck")
    public Integer insertCheck(Integer uid,Integer aid){
        Integer step=getStepByAid(aid);
        Integer collegeId=getCollegeIdBySchool(uid);
        if(step==1){
            return this.checkService.insertCheck(uid,aid);}
        else{
            return this.checkService.insertCheck(collegeId,aid);
        }
    }
    public Integer getStepByAid(Integer aid){
        return this.checkService.getStepByAid(aid);
    }
    public Integer getCollegeIdBySchool(Integer sid){
        return this.checkService.getCollegeIdBySchool(sid);
    }

    //审查学生：
    @GetMapping("/checkPassStudent")
    public Integer checkPassStudent(Integer uid,Integer aid){
        return this.checkService.checkPassStudent(uid,aid);
    }
    @GetMapping("/checkNotPassStudent")
    public Integer checkNotPassStudent(Integer uid,Integer aid){
        return this.checkService.checkNotPassStudent(uid,aid);
    }
    @GetMapping("/queryRegistrationStatus")
    public Integer queryRegistrationStatus(Integer uid,Integer aid){
        return this.checkService.queryRegistrationStatus(uid,aid);
    }
}

